package com.fub.update;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class BuildingVersionMap {
	private Map<String, Integer> versions;
	private Map<String, Float> latitudes;
	private Map<String, Float> longitudes;

	/**
	 * Constructs a new building version map.
	 */
	public BuildingVersionMap() {
		this.versions = new HashMap<String, Integer>();
		this.latitudes = new HashMap<String, Float>();
		this.longitudes = new HashMap<String, Float>();
	}

	/**
	 * Adds a building.
	 * 
	 * @param buildingId
	 *            the id of the building
	 * @param version
	 *            the version of the building
	 */
	public void addBuilding(String buildingId, int version, float latitude,
			float longitude) {
		this.versions.put(buildingId, version);
		this.latitudes.put(buildingId, latitude);
		this.longitudes.put(buildingId, longitude);
	}

	/**
	 * Returns the id's of all buildings.
	 * 
	 * @return the id's of all buildings
	 */
	public Set<String> getBuildingsIds() {
		return this.versions.keySet();
	}

	/**
	 * Returns the version of a building.
	 * 
	 * @param buildingId
	 *            the id of the building
	 * @return the version of a building
	 */
	public int getVersion(String buildingId) {
		if (this.versions.get(buildingId) == null) {
			return -1;
		}
		return this.versions.get(buildingId);

	}

	public float getLatitude(String buildingId) {
		if (this.latitudes.get(buildingId) == null) {
			return -1;
		}
		return this.latitudes.get(buildingId);
	}

	public float getLongitude(String buildingId) {
		if (this.longitudes.get(buildingId) == null) {
			return -1;
		}
		return this.longitudes.get(buildingId);
	}

	/**
	 * Returns true, if this version map contains the building.
	 * 
	 * @param buildingID
	 *            the id of the building
	 * @return true, if this version map contains the building
	 */
	public boolean contains(String buildingID) {
		return this.versions.get(buildingID) != null;
	}

	/**
	 * Returns the number of buildings versions.
	 * 
	 * @return the number of buildings versions
	 */
	public int size() {
		return this.versions.size();
	}

}
